package nccloud.web.ct.purdaily.action;

import java.util.Map;

import nc.vo.ct.purdaily.entity.AggCtPuVO;
import nc.vo.pubapp.pattern.model.entity.bill.AbstractBill;
import nccloud.dto.scmpub.script.entity.SCMScriptResultDTO;
import nccloud.framework.core.exception.ExceptionUtils;
import nccloud.framework.service.ServiceLocator;
import nccloud.pubitf.ct.service.IEmailService;
import nccloud.web.ct.pub.action.BaseScriptAction;
import nccloud.web.ct.purdaily.utils.ResultUtil;

public class SendMailAction extends BaseScriptAction {

	@Override
	public Map<String, Object> processSuccessResult(AbstractBill[] bills, AbstractBill[] orginalBills) {
		return ResultUtil.processScriptResult(bills, orginalBills);
	}

	@Override
	public SCMScriptResultDTO execScript(AbstractBill[] bills) {
		SCMScriptResultDTO resultDTO = new SCMScriptResultDTO();
		try {
			AggCtPuVO bill = ((AggCtPuVO[]) bills)[0];
			bill = ((IEmailService) ServiceLocator.find(IEmailService.class)).SendMail(bill);
			resultDTO.setSucessVOs(bills);
			return resultDTO;
		} catch (Exception e) {
			ExceptionUtils.wrapException(e);
			return null;
		}
	}

	@Override
	public Class getClazz() {
		return AggCtPuVO.class;
	}

}
